import React, { useEffect, useState } from "react";
import { useSearchParams } from "react-router-dom";
import { wjlgetresult2 } from "../axiosAPI/wjl";
import './Look.css'; // 引入样式文件
import Watermark from "./Watermark";
export const Look = () => {
    let [search] = useSearchParams();
    let paperid = search.get("paperid");

    const [grade, setGrade] = useState("");

    const getResult = async () => {
        const {
            data: { code, grade },
        } = await wjlgetresult2({ _id: paperid });
        if (code === 200) {
            setGrade(grade);
        }
    };

    useEffect(() => {
        getResult();
    }, []);

    return (
        <div className="container">
            <Watermark></Watermark>
            <div className="result-card">
                <h1 className="result-title">考试成绩</h1>
                {grade ? (
                    <p className="result-message">
                        考生 <strong>{sessionStorage.getItem('sname')}</strong> 的考试成绩为 <span className="grade">{grade}</span>
                    </p>
                ) : (
                    <p className="result-message">暂无考试成绩</p>
                )}
            </div>
        </div>
    );
};
